<template>
  <div class="resume">
    <div class="banner"></div>

    <div class="profile">
      <div class="profile-header">
        <div class="profile-header__title">
          <h1 style="color: #34373b">我的简历</h1>
          <div>
            <label class style="color: #34373b">
              <i class="el-icon-time"></i>
              最近更新: {{ resumeDetail?.updateTime || resumeDetail?.createTime || '暂无' }}
            </label>
          </div>
        </div>
      </div>

      <div class="resumeForm" v-loading="loading">
        <!-- 基本信息 -->
        <div class="resumeViewSection">
          <h2 class="resumeViewSection__title">基本信息</h2>
          <div class="resumeViewForm">
            <div class="resumeViewItem">
              <div class="resumeViewItem__label">姓名</div>
              <div class="resumeViewItem__content">{{ resumeDetail?.resName }}</div>
            </div>
            <div class="resumeViewItem">
              <div class="resumeViewItem__label">性别</div>
              <div class="resumeViewItem__content">{{ resumeDetail?.resSex === '0' ? '男' : '女' }}</div>
            </div>
            <div class="resumeViewItem">
              <div class="resumeViewItem__label">手机号</div>
              <div class="resumeViewItem__content">{{ resumeDetail?.resPhone }}</div>
            </div>
            <div class="resumeViewItem">
              <div class="resumeViewItem__label">邮箱</div>
              <div class="resumeViewItem__content">{{ resumeDetail?.resEmail }}</div>
            </div>
          </div>
        </div>

        <!-- 自我评价 -->
        <div class="resumeViewSection" v-if="resumeDetail?.resDesc">
          <h2 class="resumeViewSection__title">自我评价</h2>
          <div class="resumeViewForm">
            <div class="resumeViewItem resumeViewItem-desc">
              {{ resumeDetail?.resDesc }}
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import store from "@/store";

export default {
  name: "resume",
  data() {
    return {
      loading: false,
      resumeDetail: {
        resName: '',
        resSex: '0',
        resPhone: '',
        resEmail: '',
        resDesc: '',
        createTime: '',
        updateTime: ''
      }
    };
  },
  methods: {
    getUserResume() {
      this.loading = true;
      
      this.$axios.post("/resume/getOne", {})
        .then(res => {
          if (res.code == 200) {
            this.resumeDetail = {
              ...this.resumeDetail,
              ...res.data
            };
          } else {
            this.$message.error(res.msg || '获取简历信息失败');
          }
        })
        .catch(err => {
          console.error('获取简历失败:', err);
          this.$message.error('获取简历信息失败');
        })
        .finally(() => {
          this.loading = false;
        });
    }
  },
  created() {
    this.getUserResume();
  }
};
</script>

<style lang="less" scoped>
.banner {
  height: 300px;
  background-repeat: no-repeat;
}

.profile {
  width: 900px;
  margin: auto;
  margin-top: -200px;
  &-header {
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-left: 400px;
  }

  .resumeForm {
    margin-top: 30px;
    background: #fff;
    box-shadow: 0px 9px 20px 0px #c2c1c180;
    border-radius: 4px;
    padding: 30px;

    .resumeViewSection {
      min-height: 200px;
      margin-bottom: 30px;
      &__title {
        margin-bottom: 20px;
      }
      .resumeViewForm {
        margin-bottom: 30px;
      }
      .resumeViewItem {
        float: left;
        width: 50%;
        margin-bottom: 20px;
        min-height: 50px;
        &__content.is-link {
          color: @main-color;
          cursor: pointer;
        }
        &__label {
          color: @secondary-text-color;
          font-size: @font-size-base;
          margin-bottom: 7px;
        }
        &__content-link {
          color: @main-color;
        }
        &-desc {
          overflow: hidden;
          width: 70%;
          white-space: pre-line;
        }
      }
    }
  }
}
</style>
